using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MKDS_Course_Editor._3DS
{
    class CBMD
    {
        public static CBMD_File Read(string infile)
        {
            CBMD_File c = new CBMD_File();
            EndianBinaryReader er = new EndianBinaryReader(File.OpenRead(infile), Endianness.LittleEndian);
            c.Header.Type = er.ReadString(Encoding.ASCII, 4);
            if (c.Header.Type == "CBMD")
            {
                c.Header.Unknown1 = er.ReadInt32();
                c.Header.Headersize = er.ReadInt32();
                c.Header.Unknown2 = er.ReadBytes(c.Header.Headersize - 12);
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Error");
            }
            return c;
        }
        public struct CBMD_File
        {
            public header Header;
            public struct header
            {
                public string Type;
                public Int32 Unknown1;
                public Int32 Headersize;
                public byte[] Unknown2;
                public Int32 Filesize;
            }
        }
    }
}
